#ifndef VERIFYCODEWIDGET_H
#define VERIFYCODEWIDGET_H

#include <QWidget>
#include <QRandomGenerator>

class QPixmap;

class VerifyCodeWidget : public QWidget
{
    Q_OBJECT
public:
    explicit VerifyCodeWidget(QWidget* parent = nullptr);

    void refreshVerifyCode();
    QString getVerifyCode() const;
    bool checkVerifyCode(const QString& input) const;

protected:
    void paintEvent(QPaintEvent* event) override;
    void mousePressEvent(QMouseEvent* event) override;

private:
    void generateVerifyCode();          // 生成验证码文本
    QPixmap generateVerifyPixmap();     // 生成验证码图片

private:
    QString verifyCode;
    QPixmap cachedPixmap;               // 缓存验证码图片
    QRandomGenerator randomGenerator;
};




#endif // VERIFYCODEWIDGET_H


